package c.j.a.d.b.n;

import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.util.SparseArray;
import c.j.a.d.b.b.g;
import c.j.a.d.b.d.a0;
import c.j.a.d.b.d.b0;
import c.j.a.d.b.d.d0;
import c.j.a.d.b.d.f0;
import c.j.a.d.b.d.g0;
import c.j.a.d.b.d.h0;
import c.j.a.d.b.d.i;
import c.j.a.d.b.d.j;
import c.j.a.d.b.d.j0;
import c.j.a.d.b.d.k;
import c.j.a.d.b.d.l0;
import c.j.a.d.b.d.m0;
import c.j.a.d.b.d.q;
import c.j.a.d.b.d.s;
import c.j.a.d.b.d.t;
import c.j.a.d.b.d.u;
import c.j.a.d.b.d.v;
import c.j.a.d.b.d.w;
import c.j.a.d.b.d.x;
import c.j.a.d.b.d.z;
import c.j.a.d.b.e.l;

/* compiled from: IPCUtils */
public class d {
    public static Handler a = new Handler(Looper.getMainLooper());

    /* compiled from: IPCUtils */
    public static class e implements c.j.a.d.b.d.d {
        public final /* synthetic */ c.j.a.d.b.d.c a;

        public e(c.j.a.d.b.d.c cVar) {
            this.a = cVar;
        }

        public void J(int i, com.ss.android.socialbase.downloader.g.c cVar, String str, String str2) {
            try {
                this.a.J(i, cVar, str, str2);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public boolean a(boolean z) {
            try {
                return this.a.a(z);
            } catch (RemoteException e) {
                e.printStackTrace();
                return false;
            }
        }

        public String a() {
            try {
                return this.a.a();
            } catch (RemoteException e) {
                e.printStackTrace();
                return null;
            }
        }
    }

    /* compiled from: IPCUtils */
    public static class a extends c.j.a.d.b.d.w.a {
        public final /* synthetic */ c.j.a.d.b.d.b a;
        public final /* synthetic */ boolean b;

        /* compiled from: IPCUtils */
        public class a implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public a(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.H(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class b implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public b(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.u(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class c implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public c(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.A(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class d implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public d(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.a(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class e implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;
            public final /* synthetic */ com.ss.android.socialbase.downloader.e.a b;

            public e(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
                this.a = cVar;
                this.b = aVar;
            }

            public void run() {
                a.this.a.R(this.a, this.b);
            }
        }

        /* compiled from: IPCUtils */
        public class f implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;
            public final /* synthetic */ com.ss.android.socialbase.downloader.e.a b;

            public f(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
                this.a = cVar;
                this.b = aVar;
            }

            public void run() {
                a.this.a.N(this.a, this.b);
            }
        }

        /* compiled from: IPCUtils */
        public class g implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public g(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                ((g0) a.this.a).P(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class h implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public h(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.b(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class i implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public i(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.c(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class j implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public j(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.x(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class k implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;

            public k(com.ss.android.socialbase.downloader.g.c cVar) {
                this.a = cVar;
            }

            public void run() {
                a.this.a.D(this.a);
            }
        }

        /* compiled from: IPCUtils */
        public class l implements Runnable {
            public final /* synthetic */ com.ss.android.socialbase.downloader.g.c a;
            public final /* synthetic */ com.ss.android.socialbase.downloader.e.a b;

            public l(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
                this.a = cVar;
                this.b = aVar;
            }

            public void run() {
                a.this.a.z(this.a, this.b);
            }
        }

        public a(c.j.a.d.b.d.b bVar, boolean z) {
            this.a = bVar;
            this.b = z;
        }

        public void A(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            c.j.a.d.b.d.b bVar = this.a;
            if (!(bVar instanceof g0)) {
                return;
            }
            if (this.b) {
                d.a.post(new g(cVar));
            } else {
                ((g0) bVar).P(cVar);
            }
        }

        public void D(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new k(cVar));
            } else {
                this.a.D(cVar);
            }
        }

        public void H(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new a(cVar));
            } else {
                this.a.H(cVar);
            }
        }

        public void N(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) throws RemoteException {
            if (this.b) {
                d.a.post(new f(cVar, aVar));
            } else {
                this.a.N(cVar, aVar);
            }
        }

        public void P(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new b(cVar));
            } else {
                this.a.u(cVar);
            }
        }

        public void R(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) throws RemoteException {
            if (this.b) {
                d.a.post(new e(cVar, aVar));
            } else {
                this.a.R(cVar, aVar);
            }
        }

        public int a() throws RemoteException {
            return this.a.hashCode();
        }

        public void b(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new h(cVar));
            } else {
                this.a.b(cVar);
            }
        }

        public void c(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new i(cVar));
            } else {
                this.a.c(cVar);
            }
        }

        public void u(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new c(cVar));
            } else {
                this.a.A(cVar);
            }
        }

        public void x(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new j(cVar));
            } else {
                this.a.x(cVar);
            }
        }

        public void z(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) throws RemoteException {
            if (this.b) {
                d.a.post(new l(cVar, aVar));
            } else {
                this.a.z(cVar, aVar);
            }
        }

        public void a(com.ss.android.socialbase.downloader.g.c cVar) throws RemoteException {
            if (this.b) {
                d.a.post(new d(cVar));
            } else {
                this.a.a(cVar);
            }
        }
    }

    /* compiled from: IPCUtils */
    public static class b extends c.j.a.d.b.h.a.a {
        public final /* synthetic */ c.j.a.d.b.h.c a;

        public b(c.j.a.d.b.h.c cVar) {
            this.a = cVar;
        }

        public com.ss.android.socialbase.downloader.g.c a() throws RemoteException {
            return this.a.a;
        }

        public s b() throws RemoteException {
            l lVar = this.a.c;
            if (lVar == null) {
                return null;
            }
            return new y(lVar);
        }

        public c.j.a.d.b.d.c c() throws RemoteException {
            return d.b(this.a.i);
        }

        public i d() throws RemoteException {
            j jVar = this.a.q;
            if (jVar == null) {
                return null;
            }
            return new p(jVar);
        }

        public v e() throws RemoteException {
            m0 m0Var = this.a.j;
            if (m0Var == null) {
                return null;
            }
            return new z(m0Var);
        }

        public t f() throws RemoteException {
            b0 b0Var = this.a.k;
            if (b0Var == null) {
                return null;
            }
            return new w(b0Var);
        }

        public j0 g() throws RemoteException {
            l0 l0Var = this.a.n;
            if (l0Var == null) {
                return null;
            }
            return new r(l0Var);
        }

        public k h() throws RemoteException {
            c.j.a.d.b.e.s sVar = this.a.p;
            if (sVar == null) {
                return null;
            }
            return new q(sVar);
        }

        public d0 i() throws RemoteException {
            f0 f0Var = this.a.o;
            if (f0Var == null) {
                return null;
            }
            return new v(f0Var);
        }

        public x j() throws RemoteException {
            q qVar = this.a.l;
            if (qVar == null) {
                return null;
            }
            return new x(qVar);
        }

        public u k() throws RemoteException {
            h0 h0Var = this.a.s;
            if (h0Var == null) {
                return null;
            }
            return new s(h0Var);
        }

        public z l() throws RemoteException {
            a0 a0Var = this.a.t;
            if (a0Var == null) {
                return null;
            }
            return new b0(a0Var);
        }

        public int a(int i) throws RemoteException {
            SparseArray a = this.a.a(a.S(i));
            if (a == null) {
                return 0;
            }
            int size;
            synchronized (a) {
                size = a.size();
            }
            return size;
        }

        public w b(int i) throws RemoteException {
            c.j.a.d.b.h.c cVar = this.a;
            c.j.a.d.b.d.b bVar = (c.j.a.d.b.d.b) cVar.d.get(a.S(i));
            boolean z = true;
            if (i == 1) {
                z = false;
            }
            return d.d(bVar, z);
        }

        public w a(int i, int i2) throws RemoteException {
            SparseArray a = this.a.a(a.S(i));
            c.j.a.d.b.d.b bVar = null;
            if (a != null && i2 >= 0) {
                synchronized (a) {
                    if (i2 < a.size()) {
                        bVar = (c.j.a.d.b.d.b) a.get(a.keyAt(i2));
                    }
                }
            }
            boolean z = true;
            if (i == 1) {
                z = false;
            }
            return d.d(bVar, z);
        }
    }

    /* compiled from: IPCUtils */
    public static class c extends c.j.a.d.b.d.c.a {
        public final /* synthetic */ c.j.a.d.b.d.d a;

        public c(c.j.a.d.b.d.d dVar) {
            this.a = dVar;
        }

        public void J(int i, com.ss.android.socialbase.downloader.g.c cVar, String str, String str2) throws RemoteException {
            this.a.J(i, cVar, str, str2);
        }

        public boolean a(boolean z) throws RemoteException {
            return this.a.a(z);
        }

        public String a() throws RemoteException {
            return this.a.a();
        }
    }

    /* compiled from: IPCUtils */
    public static class d implements g0 {
        public final /* synthetic */ w a;

        public d(w wVar) {
            this.a = wVar;
        }

        public void A(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.u(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void D(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.D(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void H(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.H(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void N(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
            try {
                this.a.N(cVar, aVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void P(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.A(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void R(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
            try {
                this.a.R(cVar, aVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void a(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.a(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void b(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.b(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void c(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.c(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void u(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.P(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void x(com.ss.android.socialbase.downloader.g.c cVar) {
            try {
                this.a.x(cVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        public void z(com.ss.android.socialbase.downloader.g.c cVar, com.ss.android.socialbase.downloader.e.a aVar) {
            try {
                this.a.z(cVar, aVar);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    public static c.j.a.d.b.d.b a(w wVar) {
        return wVar == null ? null : new d(wVar);
    }

    public static c.j.a.d.b.d.c b(c.j.a.d.b.d.d dVar) {
        return dVar == null ? null : new c(dVar);
    }

    public static c.j.a.d.b.d.d c(c.j.a.d.b.d.c cVar) {
        return cVar == null ? null : new e(cVar);
    }

    public static w d(c.j.a.d.b.d.b bVar, boolean z) {
        return bVar == null ? null : new a(bVar, z);
    }

    public static c.j.a.d.b.h.a e(c.j.a.d.b.h.c cVar) {
        return new b(cVar);
    }

    public static void f(c.j.a.d.b.h.c cVar, c.j.a.d.b.h.a aVar, g gVar) throws RemoteException {
        SparseArray sparseArray = new SparseArray();
        for (int i = 0; i < aVar.a(gVar.ordinal()); i++) {
            w a = aVar.a(gVar.ordinal(), i);
            if (a != null) {
                sparseArray.put(a.a(), a(a));
            }
        }
        try {
            if (gVar == g.MAIN) {
                synchronized (cVar.f) {
                    cVar.d(cVar.f, sparseArray);
                }
            } else if (gVar == g.SUB) {
                synchronized (cVar.g) {
                    cVar.d(cVar.g, sparseArray);
                }
            } else if (gVar == g.NOTIFICATION) {
                synchronized (cVar.h) {
                    cVar.d(cVar.h, sparseArray);
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }
}
